from base.base_actions import BaseAction
from element.goods_detail_element import GoodsDetailElement


class GoodsDetailPage(BaseAction):
    # 点击加入购物车按钮
    def click_add_to_cart_btn(self):
        return self.click(GoodsDetailElement.ADD_TO_CART_BTN)

    # 获取 弹出框结果 用于断言
    def get_result(self):
        # 切换到iframe中, 再获取结果
        self.switch_to_frame(GoodsDetailElement.CART_IFRAME)
        result = self.find_e(GoodsDetailElement.result).text
        # 切换回原页面
        self.switch_to_default()
        return result